package com.tang.java8.FunctionalInterface;

import java.util.function.Consumer;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/3/14 17:26
 * 消费型接口
 */
public class ConsumerTest {

    public static void main(String[] args) {
        //    Consumer 消费型接口: 只有输入，没有返回值
        //    1.普通写法
        Consumer<String> consumer = new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        };
        consumer.accept("abc");



        //   2.Lambda表达式简化
        Consumer<String> consumer1 = s -> {
            System.out.println(s);
        };
        consumer1.accept("abc");
    }
}
